package com.awifi.demo.schedule;

import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.util.concurrent.LinkedBlockingQueue;

/**
 * @description: ToDo
 * @author: marin
 * @time: 2020/8/13 8:58
 */
//@Component
//@Async
public class SpringSchedule {
    public static int i = 0;
    private static LinkedBlockingQueue queue = new LinkedBlockingQueue();

    @Scheduled(cron = "0 */1 * * * ?")
    public void dealUpdateTask() {

        System.out.println("定时更新数据库操作--->开始");

        System.out.println("i:"+queue.poll());

        System.out.println("定时更新数据库操作--->结束");
    }

    @Scheduled(cron = "0 */1 * * * ?")
    public void getScheduled() {
        queue.add(i++);
    }

}
